Skip to content

vaderdaniel/SolarManExcel2DB

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

66 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

SolarManExcel2DB - Complete Web Application

Java Angular Spring Boot PostgreSQL Grafana

A modern web application for importing solar power generation data from SolarMan Excel exports into a PostgreSQL database. Features a complete full-stack implementation with Angular frontend and Spring Boot backend.

πŸ—οΈ Architecture Overview

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Œ    REST API     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Œ    JDBC     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Œ
β”‚    Angular 21   │◄────────────────►│   Spring Boot    │◄───────────►│   PostgreSQL    β”‚
β”‚     Frontend    β”‚                  β”‚     Backend      β”‚             β”‚    Database     β”‚
β”‚  (Port: 4200)   β”‚                  β”‚   (Port: 8080)   β”‚             β”‚   (Port: 5432)  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜             β””β”€β”€β”€β”€β”€β”€β”€β”€β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”Œ
                                                                                β”‚
                                                                                β”‚ Read-Only
                                                                                β”‚
                                                                       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”Œ
                                                                       β”‚     Grafana     β”‚
                                                                       β”‚   Monitoring    β”‚
                                                                       β”‚  (Port: 3000)   β”‚
                                                                       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Œ

Kubernetes Startup Sequence

When deployed to Kubernetes, init containers ensure proper startup order:

  • PostgreSQL starts first (no dependencies)
  • Backend & Grafana wait for PostgreSQL to be ready (port 5432)
  • Frontend waits for Backend to be ready (port 8080)

This prevents connection errors and ensures clean application startup.

✨ Key Features

Web UI (Version 1.7)

  • 🌐 Modern Web UI: Angular 21 with Material Design and Routing
  • πŸ“Š Production Visualization: Interactive bar chart showing last 7 days of solar production
  • ⚑ Tshwane Usage Visualization: Bar chart showing kWh consumed between the last 7 Tshwane meter readings
  • πŸ”„ Time-Weighted Calculations: Accurate energy production metrics matching Grafana dashboards
  • 🧭 Multi-Page Navigation: Dedicated Home and Upload pages with toolbar navigation
  • πŸ“Š Real-time Status: Live database connectivity monitoring with 10-second polling
  • πŸ”„ Auto-Refresh Charts: Charts automatically update after data imports
  • πŸ“‚ File Upload: Drag-and-drop Excel file processing
  • πŸ‘€ Data Preview: Review data before importing with Material tables
  • πŸš€ Full File Import: Processes thousands of records efficiently
  • πŸ“ˆ Import Results: Detailed statistics and error reporting
  • πŸ”„ Dual Support: SolarMan and Tshwane electricity data formats
  • πŸ›‘οΈ Data Validation: Comprehensive file and data validation
  • ⚑ High Performance: Optimized for large Excel files
  • 🎯 Production Ready: Complete Kubernetes deployment with Rancher Desktop
  • πŸ“Š Grafana Integration: Optional monitoring and data visualization

🚦 Quick Start

Choose Your Deployment Method

You can run the application in three different ways:

🐳 Option 1: Docker & Kubernetes (Recommended)

Run the complete application stack in containers with Kubernetes orchestration:

# 1. Build Docker images
./scripts/build-images.sh

# 2. Deploy to Kubernetes
./scripts/k8s-deploy.sh

# 3. Access the application
open http://localhost:30080

πŸ“˜ Full Docker & Kubernetes Documentation β†’

πŸ‹ Option 2: Docker Compose (Quick Testing)

Run all services with Docker Compose for quick local testing:

# Start all services
./scripts/docker-compose-up.sh

# Access the application
open http://localhost:8081

# Stop services
docker-compose down

πŸ’» Option 3: Local Development (Native)

Run components natively for active development:

Prerequisites

  • Java 17 or higher
  • Node.js 18+ and npm
  • PostgreSQL database
  • Maven 3.6+
  • Trivy (for security scanning)

1. Database Setup

# Start your PostgreSQL database
/Users/danieloots/LOOTS_PG/loots_pg.sh

# Set environment variables
export DB_USER=your_database_username
export DB_PASSWORD=your_database_password

2. Backend Setup

# Navigate to backend directory
cd backend

# Build and run Spring Boot application
mvn spring-boot:run
# Backend runs on http://localhost:8080

3. Frontend Setup

# Navigate to frontend directory
cd frontend/solarman-ui

# Install dependencies and start development server
npm install
npm start
# Frontend runs on http://localhost:4200

4. Access the Application

Open your browser to http://localhost:4200 and start importing your Excel files!

πŸ“š Documentation

This project includes comprehensive documentation organized into specialized files:

🎯 Recent Major Updates

v1.7.3 - Tshwane Electricity Usage Bar Chart (April 30, 2026)

  • βœ… New TshwaneChartComponent: Green CSS bar chart on home page between Solar Production and System Status
  • βœ… kWh per interval: Shows cumulative_electricity_used difference between each of the last 7 readings
  • βœ… New API endpoint GET /api/database/tshwane-usage using LATERAL join query
  • βœ… Auto-refresh: Reloads after Tshwane import via ChartRefreshService
  • βœ… 61 backend and 42 frontend tests passing

v1.7 - Tshwane Electricity Data Model Redesign (April 29, 2026)

  • βœ… New column cumulative_electricity_used: Stores running total from Col C of "Elektrisiteit Lesings" sheet (replacing raw meter reading)
  • βœ… Notes from Col O: Sparse milestone notes (e.g. "Prepaid Electricity Installed") now captured in reading_notes
  • βœ… reading_amount dropped: Column was always 0, now removed from schema and model
  • βœ… Upload preview updated: "Cumulative Electricity Used" column shown in data preview
  • βœ… All 56 backend and 31 frontend tests passing

v1.6 - Security Vulnerability Fixes (April 27, 2026)

  • βœ… Tomcat 10.1.54: Upgraded from 10.1.52 (CRITICAL CVE-2026-29145 auth bypass + 6 other CVEs fixed)
  • βœ… Spring Framework 6.2.17: Forced override to fix CVE-2026-22737
  • βœ… commons-lang3 3.18.0: Forced override to fix CVE-2025-48924
  • βœ… Angular 21.2.10: Upgraded from 21.1.x (XSS in i18n fixed)
  • βœ… vite & undici: Updated via @angular/build 21.2.8 (path traversal, HTTP smuggling fixed)
  • βœ… Zero frontend vulnerabilities: All 18 npm audit issues resolved

v1.5 - Dependency Upgrades & Vitest Migration (February 21, 2026)

  • βœ… Java 17: Upgraded from Java 11 to Java 17
  • βœ… Angular 21: Upgraded from Angular 20.3 to Angular 21
  • βœ… Vitest Migration: Migrated frontend tests from Karma/Jasmine to Vitest
  • βœ… Spring Boot 3.5.10: Upgraded from 3.2.2
  • βœ… Apache POI 5.5.1: Upgraded from 4.1.1
  • βœ… PostgreSQL JDBC 42.7.10: Upgraded from 42.7.3
  • βœ… Tomcat 10.1.52: Upgraded from 10.1.35

Security & Infrastructure Enhancements (February 2, 2026)

  • βœ… Security Scanning: Integrated Trivy vulnerability scanning for dependencies and Docker images
  • βœ… Grafana Backup/Restore: Comprehensive backup and restore system for dashboards and datasources
  • βœ… Tomcat Security Update: Upgraded to version 10.1.35 (CVE-2025-24813 fixed)
  • βœ… Simplified Dockerfile: Added Dockerfile.simple for runtime-only builds
  • βœ… Enhanced Documentation: New security guides and Grafana backup procedures

v1.1 - Production Visualization & Multi-Page UI

  • βœ… Production Chart: CSS-based bar chart showing 7-day solar production trends
  • βœ… Multi-Page Routing: Separated Home and Upload pages with Angular Router
  • βœ… Time-Weighted Stats: New API endpoint with Grafana-compatible calculations
  • βœ… Auto-Refresh: Charts automatically update after successful imports
  • βœ… Toolbar Navigation: Material Design navigation with active route highlighting
  • βœ… Kubernetes Deployment: Complete containerization with Rancher Desktop
  • βœ… Enhanced Architecture: Service-based chart refresh and event system

v2.0 - Full-Stack Web Application

  • βœ… Complete Rewrite: Transformed from CLI to full web application
  • βœ… Full File Import: Fixed critical issue - now imports ALL records (1,988+) instead of just preview data
  • βœ… Smart File Storage: Temporary file storage with unique IDs for reliable full imports
  • βœ… Enhanced UI: Real-time record counts, improved preview experience
  • βœ… Flexible Date Parsing: Handles multiple date formats automatically
  • βœ… Production Ready: Complete CI/CD pipeline with comprehensive testing

Key Technical Achievements

  • File Processing: Successfully handles large Excel files (tested with 1,988 records)
  • Memory Management: Efficient temporary file storage with automatic cleanup
  • Error Recovery: Robust error handling with detailed logging and user feedback
  • Performance: Optimized database operations with batch processing and UPSERT logic
  • User Experience: Intuitive workflow with clear progress indicators and validation

πŸ› οΈ Technology Stack

Frontend

  • Angular 21.2: Latest framework with standalone components
  • Angular Material: Modern Material Design components
  • TypeScript 5.9: Type-safe development environment
  • RxJS: Reactive programming for API communication
  • Vitest: Fast unit test runner (migrated from Karma/Jasmine)
  • SCSS: Advanced styling with component encapsulation

Backend

  • Spring Boot 3.5.10: Enterprise-grade Java framework
  • Spring Data JPA: Powerful ORM with PostgreSQL integration
  • Apache POI 5.5.1: Excel file processing and validation
  • Apache Tomcat 10.1.54: Embedded web server (security-patched)
  • Java 17: Runtime environment
  • Maven: Dependency management and build automation
  • Hibernate: Advanced database operations and caching
  • Trivy: Security vulnerability scanning

Database & Infrastructure

  • PostgreSQL: Robust relational database with persistent storage
  • Docker: Multi-stage builds for optimized images
  • Kubernetes: Production-ready orchestration with Rancher Desktop
  • nginx: High-performance reverse proxy for frontend
  • Grafana: Analytics and monitoring platform with PostgreSQL datasource
  • Environment Configuration: Flexible deployment options

πŸ“Š Supported Data Formats

SolarMan Excel Files

  • Production Power, Consumption Power, Grid Power
  • Battery operations (Charging, Discharging, SoC)
  • Feed-in tariff data and purchasing power
  • Timestamp validation and filtering (post-2020 data)

Tshwane Electricity Files

  • Cumulative electricity used (running total since baseline reading)
  • Milestone notes (e.g. prepaid meter installation, infrastructure changes)
  • Municipal electricity usage tracking

πŸ”„ Development Workflow

Native Development (Local)

# 1. Start Database
/Users/danieloots/LOOTS_PG/loots_pg.sh

# 2. Backend Development (Terminal 1)
cd backend
mvn spring-boot:run

# 3. Frontend Development (Terminal 2)  
cd frontend/solarman-ui
npm start

# 4. Production Build
npm run build                    # Frontend
mvn clean package               # Backend

Docker Development (Containerized)

# 1. Build all images
./scripts/build-images.sh

# 2. Run with Docker Compose
./scripts/docker-compose-up.sh

# 3. View logs
docker-compose logs -f

# 4. Stop services
docker-compose down

Kubernetes Development (Production-like)

# 1. Build images
./scripts/build-images.sh

# 2. Deploy to Kubernetes
./scripts/k8s-deploy.sh

# 3. View logs
kubectl logs -l app=backend -f

# 4. Clean up
./scripts/k8s-delete.sh

πŸš€ Production Deployment

Option 1: Kubernetes (Recommended for Production)

Deploy the complete application stack to Kubernetes with proper orchestration:

# Build Docker images
./scripts/build-images.sh

# Deploy to Kubernetes
./scripts/k8s-deploy.sh

# Access application at http://localhost:30080

For detailed deployment instructions, see AGENTS.md

Option 2: Docker Compose

Deploy with Docker Compose for simpler environments:

# Start all services
./scripts/docker-compose-up.sh

# Access application at http://localhost:8081

Option 3: Single JAR Deployment

The application builds into a single executable JAR file containing both frontend and backend:

# Build production application
cd frontend/solarman-ui && npm run build
cd ../../backend && mvn clean package

# Deploy single JAR
java -jar target/solarman-ui-backend-1.7.0.jar

# Access application at http://localhost:8080

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“„ License

This project is proprietary software. All rights reserved.

πŸ†˜ Support

For technical support or questions:

  • Check the relevant documentation files above
  • Review the issue tracker
  • Contact the development team

πŸ† Acknowledgments

  • Built with modern web development best practices
  • Optimized for solar energy data management
  • Designed for enterprise-scale deployments
  • Committed to sustainable energy monitoring

Latest Version: 1.7.3 - Tshwane Electricity Usage Bar Chart
Last Updated: April 30, 2026
Status: Production Ready βœ…

πŸ”’ Security

The application includes automated security scanning using Trivy:

# Run security scan (integrated with Maven build)
mvn verify

# Run security scan standalone
cd backend && ./security-scan.sh

Security reports are generated in backend/reports/:

  • Maven dependencies scan
  • JAR artifact scan
  • Docker image scan

For detailed security documentation, see:

πŸ“Š Grafana Dashboards

The application integrates with Grafana for data visualization:

Dashboards:

  • Daily Stats - Last 2 days with hourly heatmaps
  • Weekly Stats - ISO week aggregations
  • Monthly Stats - Long-term trends
  • By Week Number - Seasonal patterns
  • Tshwane Daily - Rolling avg electricity consumption vs grid purchased comparison

Access:

kubectl port-forward svc/grafana-service 3000:3000 -n default
open http://localhost:3000

Backup & Restore:

# Restore all dashboards
./restore-dashboards-fixed.sh

For detailed Grafana documentation, see:

πŸ“Έ Screenshots

Home Page with Production and Usage Charts

  • 7-day production bar chart with time-weighted calculations
  • Tshwane electricity usage bar chart (kWh between last 7 readings)
  • System status panel with real-time database monitoring
  • Responsive Material Design interface

Upload Page

  • File selection and preview
  • Import confirmation workflow
  • Detailed import results with statistics

Navigation

  • Toolbar with Home and Upload buttons
  • Active route highlighting
  • Seamless page transitions

About

Full-stack web application for importing and visualizing solar power data from SolarMan Excel exports. Angular + Spring Boot + PostgreSQL with Grafana dashboards and Kubernetes deployment.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors